package design;

public class SingletonTest {

    public static void main(String[] args) {
        System.out.println("--" + args.length);
        for (int i = 0; i < args.length; i++) {
            System.out.println(args[i]);
        }
    }
}

/**
 * 饿汉
 */
class Bank {

    private Bank(){}

    private static Bank b = new Bank();

    public static Bank getInstance() {
        return b;
    }

}

/**
 * 懒汉，线程不安全
 */
class Order2 {

    private Order2(){}

    private static Order2 b = null;

    public static Order2 getInstance() {
        if (b == null) {
            b = new Order2();
        }
        return b;
    }

}
